<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //   function buildZeroOrOne() {
      //     return Math.round(Math.random());
      //   }
      //   for (let index = 0; index < 100; index++) {
      //     console.log(buildZeroOrOne());
      //   }

      {
        for (let index = 0; index < 10; index++) {
          console.log(buildRandomNumByArr(["abc", 4, 9]));
        }

        function buildRandomNumByArr(numbers = []) {
          const len = numbers.length;
          if (len) {
            const index = Math.floor(Math.random() * len);
            console.log("index", index);
            return numbers[index];
          }
        }
      }
    </script>
  </body>
</html>
